package com.liang.cloud.Controller;

import com.liang.cloud.Entity.ProductCategory;
import com.liang.cloud.Service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: 余亮亮
 * @description:
 * @create: 2020-03-26 11:42:15
 **/
@RestController
@RequestMapping("/category/api")
@Api
public class ApiCategoryController {
    @Resource
    CategoryService service;


    @ApiOperation(value = "根据类目id获得", notes = "树列表")
    @GetMapping("/findOne/{categoryId}")
    ProductCategory findOne(@PathVariable("categoryId") Integer categoryId){
        return service.findOne(categoryId);
    }

    @GetMapping("/findAll")
    List<ProductCategory> findAll(){
        return service.findAll();
    }

    @GetMapping("/findAllWithPage")
    Page<ProductCategory> findAllWithPage( Pageable pageable){
        return service.findAll(pageable);
    }


    @PostMapping("/findByCategoryTypeIn")
    List<ProductCategory> findByCategoryTypeIn(@RequestBody List<Integer> categoryTypeList){
        return service.findByCategoryTypeIn(categoryTypeList);
    }


    @PostMapping("/save")
    ProductCategory sava(@RequestBody ProductCategory productCategory){
        return service.sava(productCategory);
    }
}
